$(function(){
	let reportDialog; //删除确认对话框
	let reportBtn; //删除按钮
	
	//加载删除确认对话框
	$.get(
		"comments/news-comments-report.html",
		function(html) {
			reportDialog = $(html).filter(".modal").appendTo("body");
			let from=reportDialog.find("form");
			//处理删除按钮事件
			from.on("submit", function() {
				let param=$(".reportContent").val();
				reportDialog.modal("hide");
				$.post(
					"report/report-add.do", 
					{"reportCommentId": reportBtn.data("id"),"reportContent": param},
					function(data) {
						if(data.ok) {
							toastr.success("举报成功")
							from.trigger("reset");
						} else {
							toastr.error(data.message);
							from.trigger("reset");
						}
					}, "json"
				);
				return false;
			});

		}
	);
	$("body").on("click", ".jubao", function() {
		reportBtn = $(this);
		//		console.info(deleteDialog);
		reportDialog.modal("show");
		return false;
	});
})
